---
title: Write bytes to a caller-supplied path
summary: WriteFile end-to-end process on SAIF.Services.WCF.Services.FileService.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-22
operation_id: OP-003
trigger: Caller invokes `WriteFile` over the `FileService` route, or `FaxService`/`ImagingService` constructs a `FileService` internally and calls `WriteFile` directly.
---

# OP-003: Write bytes to a caller-supplied path

WriteFile is invoked over the `FileService` route on `SAIF.Services.WCF.Services.FileService`; this page documents the process end to end, from route dispatch to the message the caller receives.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-003 |
| **Trigger** | Caller invokes `WriteFile` over the `FileService` route, or `FaxService`/`ImagingService` constructs a `FileService` internally and calls `WriteFile` directly. |
| **Entry operation** | [`WriteFile`](../contracts/file-service.md#writefile) |
| **Owning component** | `SAIF.Services.WCF.Services.FileService.WriteFile` |
| **Inputs** | Request message parts listed below |
| **Outputs** | No response payload (void) |
| **Failure behavior** | Generic SOAP fault, per [Faults and error pipeline](../faults.md) |

## Request and response

| Direction | Element | Type | Declared in | Notes |
| --- | --- | --- | --- | --- |
| Request | `path` | `string` | BCL (`System`) | Destination filesystem path; not validated or constrained. (Yes) |
| Request | `bytes` | `byte[]` | BCL (`System`) | Content to write at `path`. (Yes) |
| Response | `void` | `void` | n/a (void) | Not applicable — the operation returns no value. |

<!-- Types declared in `SAIF.Services.WCF.Contracts` are attributed to `SAIF.Framework.Core`, inferred from source and package references and marked `*`; their members are not enumerated because the external declaration was not read, marked `**`. -->

## Steps

1. Call `File.WriteAllBytes(path, bytes)` directly against the caller-supplied path with no validation, canonicalization, containment check, or authorization ([BR-WCF-004](../business-rules.md#br-wcf-004-file-operations-trust-the-caller-supplied-path)); a pre-existing file at `path` is overwritten.
   - On failure: a filesystem exception is logged by the installed error handler and surfaced to the caller as a generic SOAP fault with exception detail included.
2. Return.

## Process flow

The following diagram visualizes this process's control flow.

```mermaid
flowchart TD
    A["Write bytes to caller-supplied path"]
    B["Return."]
    A --> B
```

## Transaction and side effects

| Aspect | Finding |
| --- | --- |
| Unit of work | None |
| Commit point | Not applicable |
| Records written | None |
| Downstream calls | None |
| Shared state touched | None |
| Repeat-call behavior | Overwrites the target file on every call |

## Logging

| Surface | Written content |
| --- | --- |
| `ErrorLogErrorHandler` → `LogService` | Failure-path exception logging only, carrying method signature, calling user and exception detail; see [Faults and error pipeline](../faults.md) |

## Faults and error handling

| Failure | Fault type the caller receives | Produced by | Source |
| --- | --- | --- | --- |
| Filesystem exception | `Generic SOAP fault` | The `ErrorLogErrorHandler` installed by `[LogErrorBehavior]` | src/WCF/SAIF.Services.WCF.Host/Services/FileService.cs |

## Authorization

| Requirement | Enforced by | Source | Applies to |
| --- | --- | --- | --- |
| [None in code](../authentication-authorization.md#authorization-enforcement) | IIS authentication on the deployment (see [Activation and hosting](../activation-hosting.md)) | `src/WCF/SAIF.Services.WCF.Host/Services/FileService.cs` | This operation |

## Related documentation
- [Index](../index.md)
- [Overview](../overview.md)
- [Architecture](../architecture.md)
- [Activation and hosting](../activation-hosting.md)
- [Operations](../operations.md)
- [Faults and error pipeline](../faults.md)
- [Authentication and authorization](../authentication-authorization.md)
- [Dependencies](../dependencies.md)
- [Configuration](../configuration.md)
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [Data model](../data-model.md)
- [Operational runbook](../operational-runbook.md)
- [Tech debt](../tech-debt.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- src/WCF/SAIF.Services.WCF.Host/Services/FileService.cs
